package com.digitalart.futbol.service.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.digitalart.futbol.hibernate.ejb.Provincia;
import com.digitalart.futbol.hibernate.service.ProvinciaService;


@Controller
@RequestMapping(value="/provincia")
public class ProvinciaController {

	@Autowired
	private ProvinciaService provinciaServ;
	
	@RequestMapping(value = "/getById/{id}", method = RequestMethod.GET)
	public @ResponseBody Provincia getById(@PathVariable("id") int id) {
	
		Provincia provincia = provinciaServ.retriveProvincia(id);
		
		return provincia;
	}
	
	@RequestMapping(value = "/getAll", method = RequestMethod.GET)
	public @ResponseBody List<Provincia> getAll() {
	
		List<Provincia> provincias = provinciaServ.findAll();
		
		return provincias;
	}
	
}
